<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery-2.1.0.min.js"></script>
    <script>
        window.onload = function () {
            var $username = $("#username");
            var $password = $("#password");
            $("#btn").click(function () {
                $.ajax({
                        type : "POST",
                        url: "/ajaxse",
                        data: {"username": $username.val(), "password": $password.val()},
                        success: function (data) {
                            alert(data.username,data.password);
                        },
                        dataType:JSON,
                        contentType : "application/json"
                    }
                )
            })
        }
    </script>
</head>
<body>
<form action="/ajaxse" method="post">
    <input type="text" id="username">
    <input type="text" id="password">
</form>
<button id="btn">按钮</button>
</body>
</html>